package org.example.teachermall04.controller;

import org.example.teachermall04.entity.Admin;

import jakarta.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/admin")
public class AdminController {
    @GetMapping("")  //  /admin
    public String admin(HttpSession session) {
        Object loginUser = session.getAttribute("loginUser");
        if(loginUser instanceof Admin && ((Admin) loginUser).getAccount().equals("admin")){
            return "admin";
        }
        return "redirect:/";
    }

}
